import java.util.Scanner;

public class SignStr {

	public static void main(String[] args) {
		
		SignThread signThread = null;
		boolean isContinued = true;
		Scanner in = new Scanner(System.in);
		System.out.println("start  启动");
		 System.out.println("quit  退出");
		 System.out.println("help  帮助");
		while(isContinued)
		{		
			 System.out.print(">>");
			 String cmd = in.next();
			 if("quit".equals(cmd)){
				 if(null != signThread){
					 signThread.setOver(true);
					 try {
						 signThread.interrupt(); 
						signThread.join();
					} catch (InterruptedException e) {
						e.printStackTrace();
					} 
					 signThread = null;
					 System.out.println("设置结束成功");
				 }
				 isContinued = false;
				
			 }
			 else if("start".equals(cmd)){
				 if(null != signThread){
					 System.out.println("服务已经开启");
				 }
				 else{
					 signThread = new SignThread();
					 signThread.start();
					 System.out.println("开启线程成功"); 
				 }
			 }
			 else if("help".equals(cmd)){
				 System.out.println("start  启动");
				 System.out.println("quit  退出");
				 System.out.println("help  帮助");
			 }
			 else{
				 System.out.println("输入命令有误");
				 System.out.println("");
				 
				 System.out.println("合法命令有：");
				 System.out.println("start  启动");
				 System.out.println("quit  退出");
				 System.out.println("help  帮助");
			 }
		}
		System.out.println("服务结束");
	}

}
